/*
*	ID : Pallab
* 	PROG : E
* 	LANG : C++
* 	2012-09-16-19.35.48 Sunday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;


#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

template<class T1>
inline void debug(T1 _x) {
    cout<<_x<<'\n';
}
template<class T1, class T2>
inline void debug(T1 _x,T2 _y) {
    cout<<_x<<' '<<_y<<'\n';
}
template<class T1, class T2, class T3>
inline void debug(T1 _x,T2 _y,T3 _z) {
    cout<<_x<<' '<<_y<<' '<<_z<<'\n';
}
template<class T1, class T2, class T3, class T4>
inline void debug(T1 _x,T2 _y,T3 _z,T4 _zz) {
    cout<<_x<<' '<<_y<<' '<<_z<<' '<<_zz<<'\n';
}
template< class T1>
inline void debug(T1 _array,int _size) {
    cout<<"[";
    for (int i=0; i<_size; ++i) {
        cout<<' '<<_array[i];
    }
    puts(" ]");
}
inline bool CI(int &_x) {
    return scanf("%d",&_x)==1;
}
inline bool CI(int &_x, int &_y) {
    return CI(_x)&&CI(_y) ;
}
inline bool CI(int &_x, int &_y, int &_z) {
    return CI(_x)&&CI(_y)&&CI(_z) ;
}
inline bool CI(int &_x, int &_y, int &_z, int &_zz) {
    return CI(_x)&&CI(_y)&&CI(_z)&&CI(_zz) ;
}
inline void wait( double seconds ) {
    double endtime = clock()+( seconds* CLOCKS_PER_SEC );
    while( clock() < endtime ) {
        ;
    }
}
#if !defined( ONLINE_JUDGE )
#define debug
#endif
namespace IO {
template<class T>
inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while(c<33)c=getchar();
    while(c>33) {
        if(c=='-') {
            neg=true;
        } else {
            a= (a*10)+(c-'0');
        }
        c=getchar();
    }
    return neg?-a:a;
}
template<class T>
inline void myOut(T a) {
    if(a) {
        int v=a%10;
        myOut(a/10);
        putchar( (char)(v+'0') );
    }

}
template<class T>
inline void fastOut(T a) {
    if(a==T(0) ) {
        putchar('0');
    } else if(a<T(0)) {
        putchar('-');
        myOut(-a);
    } else {
        myOut(a);
    }
}
}
struct NODE {
    int to;
    int id;
    NODE(int to=0,int id=0):
        to(to),id(id) {
        ;
    }
};
const int MX = 100005;
int node_count;
int fool_count;
vector<NODE> adj[MX];
int tin[MX],tout[MX];
int timer;
int p[MX][21];
int B[MX];
int ans[MX];

inline void read1() {
    node_count = IO::fastIn<int>();
    int u,v;
    fo(i,node_count-1) {
        u =IO::fastIn<int>()-1;
        v =IO::fastIn<int>()-1;
        adj[u].pb( NODE(v,i) );
        adj[v].pb( NODE(u,i) );
    }
}
void dfs1(int u,int pr) {
    p[u][0]=pr;
    tin[u]=timer++;
    foit(it,adj[u]) {
        int to = it->to;
        if(to==pr)continue;
        dfs1(to,u);
    }
    tout[u]=timer++;
}
int dfs2(int v, int pr) {
    int id=-1;
    int sum=B[v];
    foit(it,adj[v]) {
        int to = it->to;
        if(to==pr) {
            id = it->id;
            continue;
        }
        sum+=dfs2(to,v);
    }
    if(id!=-1)
        ans[id]=sum;

    return sum;
}
inline bool is_ancestor(int a, int b) {
    return tin[a]<=tin[b] && tout[b]<=tout[a];
}
inline int LCA(int a, int b) {
    if( is_ancestor(a,b) )return a;
    if( is_ancestor(b,a) )return b;
    //otherwise
    for(int i=19; i>=0; --i) {
        if( !is_ancestor(p[a][i],b) ) {
            a=p[a][i];
        }
    }
    return p[a][0];
}

inline void solve() {
    timer=0;
    SET(tin,0);
    SET(tout,0);
    SET(p,0);
    SET(B,0);

    read1();
    dfs1(0,0);
    //bottom up dynamic programming
    for(int i=1; i<20; ++i) {
        for(int j=0; j<node_count; ++j) {
            p[j][i]= p[ p[j][i-1] ][i-1];
        }
    }

    fool_count=IO::fastIn<int>();
    int node_a,node_b;
    fo(i,fool_count) {
        node_a = IO::fastIn<int>()-1;
        node_b = IO::fastIn<int>()-1;
        int l = LCA(node_a, node_b);
        //cout<<node_a+1<<' '<<node_b+1<<' '<<l+1<<'\n';
        B[node_a]++;
        B[node_b]++;
        B[l]-=2;
    }

    dfs2(0,-1);

    fo(i,node_count-1) {
        IO::fastOut( ans[i] );
        putchar(' ');
    }
    line;
}
int main() {
    int kase=1;
#if !defined ( ONLINE_JUDGE )
    freopen("in","r",stdin);
    kase=1;
#endif
    fo(i,kase) {
        solve();
    }
    return 0;
}


